package com.unicom.auth.kit;

import java.util.List;

public class SQLKits {
	public static String getInItemsByList(List<String> items){
		
		StringBuilder builder = new StringBuilder();
		builder.append("(");
		for (int i = 0; i < items.size(); i++) {
			builder.append("'").append(items.get(i)).append("'");
			if (i != items.size() - 1) {
				builder.append(",");
			}
		}
		builder.append(")");
		return builder.toString();
	}
	
	public static String geneInForLong(String field,List<Long> items) {
		StringBuilder builder = new StringBuilder();
		if (items.size()==0) {
			return " "+field+" in (-999999) ";
		}
		builder.append(" "+field+" in(");
		for (int i = 0; i < items.size(); i++) {
			builder.append(items.get(i));
			if (i != items.size() - 1) {
				builder.append(",");
			}
		}
		builder.append(") ");
		return builder.toString();
	}
	
	public static String geneInForStr(String field,List<String> items) {
		StringBuilder builder = new StringBuilder();
		if (items.size()==0) {
			return " "+field+" in ('') ";
		}
		builder.append(" "+field+" in('");
		for (int i = 0; i < items.size(); i++) {
			builder.append(items.get(i));
			if (i != items.size() - 1) {
				builder.append("','");
			}
		}
		builder.append("') ");
		return builder.toString();
	}
}
